package com.zhiche.lisa.tms.service.impl;


import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.zhiche.lisa.tms.dao.mapper.ShipmentPositionMapper;
import com.zhiche.lisa.tms.dao.model.ShipmentPosition;
import com.zhiche.lisa.tms.service.IShipmentPositionService;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 装车单在途信息 服务实现类
 * </p>
 *
 * @author qichao
 * @since 2018-06-18
 */
@Service
public class ShipmentPositionServiceImpl extends ServiceImpl<ShipmentPositionMapper, ShipmentPosition> implements IShipmentPositionService {

    @Override
    public Map<String, Object> currrentUploadCount(String shipmentCode) {

        Map<String, Object> dataMap = new HashMap<>();

        EntityWrapper<ShipmentPosition> ew = new EntityWrapper<>();
        ew.eq("shipment_code", shipmentCode);
        ew.addFilter("year(gmt_create)=year(now()) and month(gmt_create)=month(now()) and day(gmt_create)=day(now())");
        List<ShipmentPosition> shipmentPositionList = selectList(ew);
        dataMap.put("num", shipmentPositionList.size());

        if (shipmentPositionList.size() > 0) {
            dataMap.put("position", shipmentPositionList.get(0).getAddrText());
        }

        return dataMap;
    }
}
